﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace WordDowngrade
{
    public class ConfigFile
    {
        private String fileName;
        public ConfigFile(String fileName)
        {
            this.fileName = fileName;
        }
        public void SaveToFile(CategoryDict dict)
        {
            Stream stream = File.Open(fileName, FileMode.Create);
            BinaryFormatter bformatter = new BinaryFormatter();
            bformatter.Serialize(stream, dict);
            stream.Close();
        }
        public CategoryDict getFromFile()
        {
            CategoryDict dict = null;
            Stream stream = File.Open(fileName, FileMode.Open);
            BinaryFormatter bformatter = new BinaryFormatter();
            dict = (CategoryDict)bformatter.Deserialize(stream);
            stream.Close();
            return dict;
        }
    }
}
